[C++-sig] pyplusplus tutorials & GUI wizard
roman.yakovenko at gmail.com
Wed Feb 8 07:49:57 CET 2006
On 2/7/06, Matthias Baas <baas at ira.uka.de> wrote:
> decls = declarations.filtering.user_defined( decls_all, declfilter )
> creator = module_creator.creator_t(
> decls = decls,
> module_name = "_api",
> recursive = True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive should be set to False
When you should set recursive to true?
In case you want to export all declarations found in class or namespace.
void sort_team( foo::team& );
Lets say you want to expose only declarations found in namespace foo.
The best way to do it is next:
decls = parser.parse(["foo.h"])
namespace_foo = declarations.find_declaration( decls
, name="foo" )
extmodule = module_creator.create( decls=namespace_foo
, recursive=True )
In all other cases recursive should be set to False.
Now I understand why you have been confused.
1. Lack of documentation.
2. The way how filters work:
As input to filters you give declarations tree, as output you get
a list, that contains
all declarations, that filter input function has said true for them.
There are few reasons why this is done in this way:
1. To mimic Python build-in filter function behaviour
1.1 don't modify a state of input argument
1.2 construct new list
1.3 Fill it with items, for them input function has returned true.
2. Performance reasons:
I can create a copy of all declarations and return declarations tree,
but this approach is too expensive in time and memory
3. I could modify an input argument - input declarations tree. But
has price: it removes valuable information and could lead to
generated code that
could not be compiled.
void set_birthday(unsigned int year, unsigned int
month, unsigned int day);
void set_birthday(const std::string& birthday);
Lets say that you want to expose first member function and not second.
Using filter functionality you removes second set_birthday
declarations tree. Now you are missing important information:
is overloaded or not.
Hope, this explanation was helpful. I am open to suggestions and comments.
It would be nice to get your opinion how I can improve the interface.
C++ Python language binding
More information about the Cplusplus-sig