Re: [pygccxml-development] Py++ generates wrappers for final classes
Brought to you by:
mbaas,
roman_yakovenko
|
From: Julian S. <jul...@rs...> - 2007-07-09 08:00:25
|
Hello,
many thanks for your quick reply.
Roman Yakovenko wrote:
> On 7/9/07, Julian Scheid <jul...@rs...> wrote:
>> 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() {}
>> };
>
> What compiler do you use? I just checked this on MSVC 7.1 and it works
> fine.
> I attach the generated code.
That was a bad example - it actually compiles for me, too. But the
following won't compile on g++ 3.x (tested 3.4.2, 3.4.1 and 3.3.1) with
"base `Foo' with only non-default constructor in class without a
constructor". It works fine on g++ 4.0.2 though... so maybe it's not
something that needs to be fixed after all.
class Foo
{
public:
virtual void foo() {}
private:
Foo(bool) {}
};
I've attached the generated code as well. But it looks like it's sort of
a non-issue after all, sorry if I wasted your time.
>> 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 )
True, but wouldn't the private constructor have to be "public" from the
point of view of the deriving class? If you take a closed API that uses
private constructors like this, for example, it effectively means that
you can't subclass the class in question short of tinkering with the header.
I guess at any rate it would be great if Py++ could add a (simple) way
to explicitly disable wrapper generation for a given class.
>> Is there a short-term workaround for this problem?
>
> Try this:
I'll give that a try, thanks again for your help!
Julian
|