Thread: [pygccxml-development] skipping base classes
Brought to you by:
mbaas,
roman_yakovenko
From: Ken M. <ke...@dn...> - 2008-09-17 13:06:14
|
Hello all, After reading through the archives, docs, and the source code I cannot find out a way to do the following. Say I have a class hierarchy like this: class A [...] class B : public A [...] class C : public B [...] I need to expose to python the classes A and C, but not B. When writing the boost::python code manually I do this: bp::class_<C, bp::bases<A> >("C") So that in python it thinks that C inherits directly from A and it all works. But now that I'm using Py++ I cannot figure out a way to achieve the same thing and I have to expose the intermediate classes, which for various reasons I really don't want to do. So is there a way to do what I want in Py++? Thanks. --Ken |
From: Roman Y. <rom...@gm...> - 2008-09-17 14:08:56
|
On Wed, Sep 17, 2008 at 4:06 PM, Ken McGaugh <ke...@dn...> wrote: > Hello all, > > After reading through the archives, docs, and the source code I cannot > find out a way to do the following. > > Say I have a class hierarchy like this: > > class A > [...] > > class B : public A > [...] > > class C : public B > [...] > > I need to expose to python the classes A and C, but not B. When writing > the boost::python code manually I do this: > > bp::class_<C, bp::bases<A> >("C") > > So that in python it thinks that C inherits directly from A and it all > works. But now that I'm using Py++ I cannot figure out a way to achieve > the same thing and I have to expose the intermediate classes, which for > various reasons I really don't want to do. > > So is there a way to do what I want in Py++? I am not sure. I never tested such case. Try to exclude "B" and see what happens. If it doesn't work I will have to tweak Py++ to support such case. It should not be too difficult. One possible work around is to export class "B", but without any members and to give it pretty ugly alias, starting with '__'. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Ken M. <ke...@dn...> - 2008-09-17 14:26:55
|
Roman Yakovenko wrote: > On Wed, Sep 17, 2008 at 4:06 PM, Ken McGaugh <ke...@dn...> wrote: > >> Hello all, >> >> After reading through the archives, docs, and the source code I cannot >> find out a way to do the following. >> >> Say I have a class hierarchy like this: >> >> class A >> [...] >> >> class B : public A >> [...] >> >> class C : public B >> [...] >> >> I need to expose to python the classes A and C, but not B. When writing >> the boost::python code manually I do this: >> >> bp::class_<C, bp::bases<A> >("C") >> >> So that in python it thinks that C inherits directly from A and it all >> works. But now that I'm using Py++ I cannot figure out a way to achieve >> the same thing and I have to expose the intermediate classes, which for >> various reasons I really don't want to do. >> >> So is there a way to do what I want in Py++? >> > > I am not sure. I never tested such case. Try to exclude "B" and see > what happens. > When "B" is excluded then Py++ wraps the node with no bases listed whatsoever. > If it doesn't work I will have to tweak Py++ to support such case. It > should not be too difficult. > The way I imagine it working is that Py++ would list as the base class the first ancestor which has not been excluded. > One possible work around is to export class "B", but without any > members and to give it pretty ugly alias, starting with '__'. > Thanks, I'll give that a try. My main concern is getting the size of the module down, and I imaging a class with no members should be fairly light-weight. Thanks again. --Ken |
From: Roman Y. <rom...@gm...> - 2008-09-18 10:50:58
|
On Wed, Sep 17, 2008 at 5:26 PM, Ken McGaugh <ke...@dn...> wrote: > The way I imagine it working is that Py++ would list as the base class > the first ancestor which has not been excluded. My view is different: if you exclude base class, in this case you want to "remove" it from hierarchy. Obviously the choice is arguable. > Thanks, I'll give that a try. My main concern is getting the size of > the module down, and I imaging a class with no members should be fairly > light-weight. I think you are right. The binary size, heavily depends on number and complexity of template instantiations. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |