Re: [pygccxml-development] Pulling methods from base class without exposing base class
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-09-19 18:51:57
|
On 9/19/06, Allen Bierbaum <al...@vr...> wrote: > I am having trouble wrapping a class right now. The problem is that the > class uses template base classes to mixin functionality. This makes it > appear to pygccxml that the class has a half-dozen base classes. But I > don't want to expose these base classes, all I want to expose is the > class that is composed from the mixin functionality. I understand. > To make matters > worse there is something in the handling of these mixins that is making > pyplusplus code creators expose them all as having the same name > ("Inherited"). I think this is because each mixin class uses a typedef > called Inherited to keep track of the class that it is inheriting from. This is the right guess. > (I have attached a file that shows the basic idea, but it is a vast > simplification of the case I am really trying to handle) > > Anyway, to make a long story short, what I would like to do is just tell > pyplusplus to ignore the base classes (ie. don't expose them) but to > instead pull all of the methods defined in those base classes into the > derived class I am trying to expose. Then the generated code would only > create a wrapper for the derived class and would just create "def"'s > that reference the methods from the mixins. > > Is this possible? What do you think? Before I answer the question, I would like to make it clear: this is not "the main success scenario", so you will have to touch here and there few low level details. 1. create module_builder_t object and pass "optimize_queries=False" as a parameter. 2. Using adopt_declaration and remove_declaration methods of declarations.class_t put the method into right place. Be careful! Declaration can have only 1 parent. So if you have few derived classes you will have to "copy" declaration and to add the copy to every derived class. 3. after you finished to modify the declarations tree, run query optimizer mb.run_query_optimizer() 4. don't forget to exclude the base classes. I think this should work and it does not require too much work. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |