Re: [pygccxml-development] questions about inheritance
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2008-02-28 19:54:56
|
On Thu, Feb 28, 2008 at 7:33 PM, Kevin Watters <kev...@gm...> wrote: > I'm using Py++ with a complex class hierarchy with lots of virtual methods. It should not be a problem > As one example, wxWindow inherits from wxObject. But Py++ is > generating class wrappers which don't reflect any inheritance at all. > The class declaration for wxWindow looks like > > bp::class_< wxWindow, boost::noncopyable >( "Window" ) > .def( bp::init< >() ) > .def( bp::init< wxWindow *, wxWindowID, bp::optional< wxPoint > const &, wxSize const &, long int, wxString const & > >(( > bp::arg("parent"), bp::arg("winid"), bp::arg("pos")=wxDefaultPosition, > bp::arg("size")=wxDefaultSize, bp::arg("style")=(long int)(0), > bp::arg("name")=wxString(wxPanelNameStr) )) ) > > > Note the missing bp::bases. > > Oddly enough, if I load up a module builder in a console and query > wxWindow for its bases with the "recursive_bases" property, I see that > pygccxml has successively pulled out a chain of classes that looks > correct: "wxWindow -> wxCocoaNSView -> wxWindowBase -> wxEvtHandler -> > wxTrackable -> wxObject" > > By which criteria does Py++ decide to expose inhertiance? Do I need to > "include" each of the classes listed in wxWindow's recursive_bases > property? What if I want just the wxObject methods to be exposed? I read your script. I think I understand what the problem is. Take a look on this document. http://language-binding.net/pyplusplus/documentation/tutorials/module_builder/module_builder.html#declarations-customization I guess this is the problem. You can check it by testing "ignore" value mb.class_( 'wxObject' ).ignore Basically I suggest you to exclude everything and than to include all declarations you want to expose. mb = module_builder_t(...) mb.global_ns.exclude() mb.classes( lambda decl: decl.startswith( 'wx' ) ).include() > (For reference, my code generator is at > http://code.google.com/p/wxpy/source/browse/trunk/generate_code.py) Why do you use so much try...except blocks? For example: try: mb.mem_funs(name = 'CloneGDIRefData').exclude() except: pass If the function is there Py++ will find it an exclude, if it not there, than exception will be thrown and you will be noted that the were some changes in source files? I ask, because I want to understand whether the problem in Py++ interface or this is just your use case. > Any help is much appreciated! HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |