Re: [pygccxml-development] Implicit virtual functions in derived classes
Brought to you by:
mbaas,
roman_yakovenko
From: Julian S. <jul...@rs...> - 2008-02-16 01:06:25
|
Roman Yakovenko wrote: >> This will not generate a wrapper for B even though B inherits A's >> virtual function. Now if I have the following Python code: >> >> class C(B): >> def foo(self): >> print "C.foo" >> >> ... then when foo() is invoked on this instance on the C++ side of >> things, the Python code won't be executed as the wrapper is missing. > > Thank you very much for bug reporting. Few minutes ago I committed fix > and added new test case. > > The whole revision content: > http://pygccxml.svn.sourceforge.net/viewvc/pygccxml?view=rev&revision=1238 > > The fix: > http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py?r1=1238&r2=1237&pathrev=1238 > > I tested the fix again Py++ 0.9.5, but I guess it will also work for > your version too. Thanks for your quick response. In the meantime I arrived at a similar solution but I found that just adding non-pure virtual functions to the "redefined_funcs" list alone, as in your patch, didn't do the trick. In addition, I had to do the following (this is against Py++ 0.9.0): - Make sure that the original function is not ignored and is exportable - Make sure it is not static (weird, I know, because static methods should never be virtual - yet for some reason a few static methods ended up in the query results.) - Make sure the original function is actually defined in the base class and not in an inner class of the base class. So my code looks roughly like this: funcs.update( base_cls.member_functions( query | (all_virtual & declarations.custom_matcher_t( lambda decl: decl.parent.alias == base_cls.alias and not decl.has_static and not decl.ignore and decl.exportable), allow_empty=True ) ) I might have a bug at another point in my generate_code.py so take this with a grain of salt - not sure why all of this is necessary. I'll try again with your HEAD and let you know how I go. Just a heads up that possibly it's not that trivial. I'm also not sure whether your only including public virtual functions is correct. Unless I'm missing something, if you declare the "foo" function in my original example protected instead of public you'd still expect it to be overridable. Thanks, Julian |