Re: [pygccxml-development] Py++ generates wrappers for final classes
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2007-07-09 06:08:05
|
On 7/9/07, Julian Scheid <jul...@rs...> wrote: > Hello, > > I've run into a problem with Py++ (both with 0.9.0 and with trunk) when > trying to expose a class like this: > > class Foo > { > public: > virtual void bar() {} > private: > Foo() {} > }; > > Py++ will generate a wrapper for Foo (since it contains a virtual > function) when it shouldn't. Firstly, the generated code will not > compile because the wrapper is derived from Foo and Foo cannot be used > as a base class (Foo is final because it has no public or protected > constructors.) What compiler do you use? I just checked this on MSVC 7.1 and it works fine. I attach the generated code. > > And it doesn't make sense to generate a wrapper for Foo in the first > place because Foo is final, and so function bar() cannot be overridden > anyway. May be you are right, I should think about it. > In the long term, I guess the proper fix is to not create wrappers for > final classes. There is no such definition in C++ as "final class". Private constructor is "public" for a function or another class. ( friend ) > Is there a short-term workaround for this problem? Try this: from pygccxml import declarations mb.mem_fun('bar').virtuality = declarations.FUNCTION_VIRTUALITY_TYPES.NOT_VIRTUAL For me it generated next code: BOOST_PYTHON_MODULE(final_classes){ bp::class_< final_classes::Foo, boost::noncopyable >( "Foo", "documentation", bp::no_init ) .def( "bar" , &::final_classes::Foo::bar , "documentation" ); } Anyway I committed new test case "final_classes_tester.py". > I tried using finalize() from goodie_utils but that didn't work unfortunately. Basically this is the code contributed by other developers and I don't support it. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |