[C++-sig] single-declaration code generation in Py++

Roman Yakovenko roman.yakovenko at gmail.com
Mon May 10 06:25:08 CEST 2010


On Sun, May 9, 2010 at 10:52 PM, Jim Bosch <talljimbo at gmail.com> wrote:
> I'm a relatively experienced boost.python user trying to take my first steps
> with Py++, and I find that what I'd often like to do is just use Py++ to
> declare a single class here and there, or perhaps just some members of a
> class, and then be able to insert those bits of code into C++ source files I
> mostly write manually.
>
> This is of course the opposite of the main Py++ paradigm, in which one
> inserts snippets of custom code into a automatically-generated module, but
> seems like all the functionality to do this must already present in Py++ - I
> just need to extract pieces of the declaration tree by name, and generate
> declaration and registration boost.python code for those individually
> (preferably as Python strings rather than separate files).
>
> I'm not afraid to dive into the source to figure out how to do this, but I'd
> appreciate it if anyone has any tips or suggestions on where to get started.

It should not be too difficult. I suggest you to read this document (
http://language-binding.net/pyplusplus/documentation/architecture.html#code-generation-engine
), especially "code creators" sections. Then take a look on
'pyplusplus/file_writers/( single_file.py and multiple_files.py )
modules.

pyplusplus/code_creators/algorithm.py has some code, that helps to
work with "code creators tree".

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


More information about the Cplusplus-sig mailing list